class Solution {
public:
    int minCostClimbingStairs(vector<int>& cost) {
        if(cost.size() == 1) return cost[0];
        int a = cost[0], b = cost[1], c = 0;
        for(int i = 2; i < cost.size(); i++)
        {
            c = min(a, b) + cost[i];
            a = b, b = c;
        }
        return min(a, b);
    }
};